package test2;
//比赛选手成绩
public class Gymnastics implements ComputerAverage{
    @Override
    public double average(double[] x) {
        if (x == null || x.length == 0) {
            System.out.println("数组不能为空或长度为0");
        }
        double maxScore = Double.MIN_VALUE;
        double minScore = Double.MAX_VALUE;

        double sum1 = 0;
        for (double number : x){
            if (number > maxScore) {
                maxScore = number;
            }
            if (number < minScore) {
                minScore = number;
            }
            sum1 += number;

        }
        double adSum = sum1 - maxScore - minScore;
        return  adSum / (x.length - 2);
    }

}
